﻿/*
 * 审核中报告。2009-8-4
 * 此UI只显示待审核，或审核中的那些报告。 那些当前用户有权审核的报告，则按钮可用。
 * 
 * 状态标志100，标识报告待整理。
 * 这里有【开始整理】按钮列，当且仅当点击【开始整理】按钮列之后，才能显示【查看/编辑】按钮列。
 * 
 * */

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EQT.Model;
using EQT.Dal;

public partial class ReportQueryF1000 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //绑定仅报告组可以看的列表
            Utility.BindListCtl2Dic(DropDownListStatus, ContractStatusCollection.ConfirmGrpStatus);
            InitDefaultFitler();
            LoadContractList();
        }


    }

    private void InitDefaultFitler()
    {
        DateTime default_begin_day = new DateTime(DateTime.Today.Year, 1, 1);
        TextBoxBegin.Text = default_begin_day.ToString(SiteConfig.DateFormat);
        TextBoxEnd.Text = DateTime.Now.AddDays(1).ToString(SiteConfig.DateFormat);
        DropDownListStatus.SelectedIndex = DropDownListStatus.Items.IndexOf(DropDownListStatus.Items.FindByValue(ContractStatus.ALL.ToString()));
        TextBoxReportId.Text = String.Empty;
        TextBoxCorpName.Text = String.Empty;
    }


    protected void GridViewContracts_RowDataBound(object sender, GridViewRowEventArgs e)
    {

    }


    protected void GridViewContracts_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "start_opt")
        {
            //单击了【开始整理】
        }
    }
    /// <summary>
    /// 加载合同列表
    /// </summary>
    private void LoadContractList()
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        //时间范围是必须的
        sb.Append(DaContract.SELECT_CONTRACTS_FILEDS);
        sb.Append(Utility.GenerateQueryFilter2DateTime("CREATE_TIME", TextBoxBegin.Text, TextBoxEnd.Text));
        string filter = Utility.GenerateQueryFilterString("Report_ID", TextBoxReportId.Text, 2);
        if (filter != null) sb.AppendFormat(" AND {0} ", filter);
        filter = Utility.GenerateQueryFilterString("Corp_Name", TextBoxCorpName.Text, 2);
        if (filter != null) sb.AppendFormat(" AND {0} ", filter);

        sb.AppendFormat(" AND {0}", Utility.GenerateQueryFilterIntMaskAnd("Report_Status", "&", Int32.Parse(DropDownListStatus.SelectedValue)));
        string sql = sb.ToString();
        if (Utility.GlobalLog.IsDebugEnabled) Utility.GlobalLog.Debug(sql);
        int totalCount = 0;
        DataSet ds = DaCommon.GetPaginationData(sql,
            SiteConfig.PageSize, AspNetPager1.CurrentPageIndex - 1, "Create_Time DESC", out totalCount);
        AspNetPager1.PageSize = SiteConfig.PageSize;
        AspNetPager1.RecordCount = totalCount;
        GridViewContracts.DataSource = ds;
        GridViewContracts.DataBind();

    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        LoadContractList();
    }
    protected void btnFilterQuery_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 0;
        LoadContractList();
    }
    protected void btnQueryAll_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 0;
        InitDefaultFitler();
        LoadContractList();
    }
}
